//
//  ExaminationRoomCell.m
//  CoachsBook
//
//  Created by huiyong li on 2022/8/24.
//

#import "ExaminationRoomCell.h"
@interface ExaminationRoomCell()

@property(nonatomic,strong) UIView *bjview;
@property(nonatomic,strong) UILabel *nameTitleLabel;
@property(nonatomic,strong) UILabel *nameLabel;
@property(nonatomic,strong) UILabel *addressTitleLabel;
@property(nonatomic,strong) UILabel *addressLabel;
@property(nonatomic,strong) UILabel *carTypeTitleLabel;
@property(nonatomic,strong) UILabel *carTypeLabel;


@end
@implementation ExaminationRoomCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier

{
    if (self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier])
    {
        [self setupUI];
        self.contentView.backgroundColor = rgba(255, 255, 255, 1);
    }
    return self;
}

- (void)setupUI
{
    self.bjview = [[UIView alloc]initWithFrame:CGRectMake(16, 0, APPwidth-32, 205)];
    self.bjview.backgroundColor = rgba(245, 245, 250, 1);
    self.bjview.layer.cornerRadius = 8;
    self.bjview.layer.masksToBounds = YES;
    [self.contentView addSubview:self.bjview];
    
    
    self.nameTitleLabel = [[UILabel alloc]initWithFrame:CGRectMake(15, 10, 70, 20)];
    self.nameTitleLabel.font = kPingFangRegular(14);
    self.nameTitleLabel.textColor = rgba(51, 51, 51, 1);
    self.nameTitleLabel.text = @"考场名称:";
    [self.bjview addSubview:self.nameTitleLabel];
    
    self.nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(self.nameTitleLabel.frame)+8, 10, APPwidth-55-CGRectGetMaxX(self.nameTitleLabel.frame), 20)];
    self.nameLabel.font = kPingFangRegular(14);
    self.nameLabel.textColor = rgba(51, 51, 51, 1);
    self.nameLabel.numberOfLines = 0;
    [self.bjview addSubview:self.nameLabel];
    
    
    
    self.addressTitleLabel = [[UILabel alloc]initWithFrame:CGRectMake(15, CGRectGetMaxY(self.nameLabel.frame)+10, 70, 20)];
    self.addressTitleLabel.font = kPingFangRegular(14);
    self.addressTitleLabel.textColor = rgba(51, 51, 51, 1);
    self.addressTitleLabel.text = @"考场地址:";
    [self.bjview addSubview:self.addressTitleLabel];
    
    self.addressLabel = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(self.addressTitleLabel.frame)+8, CGRectGetMaxY(self.nameLabel.frame)+10, APPwidth-55-CGRectGetMaxX(self.addressTitleLabel.frame), 20)];
    self.addressLabel.font = kPingFangRegular(14);
    self.addressLabel.textColor = rgba(51, 51, 51, 1);
    self.addressLabel.numberOfLines = 0;
    [self.bjview addSubview:self.addressLabel];
    
    
    
    self.carTypeTitleLabel = [[UILabel alloc]initWithFrame:CGRectMake(15, CGRectGetMaxY(self.addressLabel.frame)+10, 70, 20)];
    self.carTypeTitleLabel.font = kPingFangRegular(14);
    self.carTypeTitleLabel.textColor = rgba(51, 51, 51, 1);
    self.carTypeTitleLabel.text = @"考试车型:";
    [self.bjview addSubview:self.carTypeTitleLabel];
    
    self.carTypeLabel = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(self.carTypeTitleLabel.frame)+8, CGRectGetMaxY(self.addressLabel.frame)+10, APPwidth-55-CGRectGetMaxX(self.carTypeTitleLabel.frame), 20)];
    self.carTypeLabel.font = kPingFangRegular(14);
    self.carTypeLabel.textColor = rgba(51, 51, 51, 1);
    self.carTypeLabel.numberOfLines = 0;
    [self.bjview addSubview:self.carTypeLabel];
    
    
    
}


-(void)cellFillWithModel:(ExaminationRoomModel *)model
{
    
    self.nameLabel.text = model.ExaminationRoomName;
    self.addressLabel.text = model.ExaminationRoomAddress;
    self.carTypeLabel.text = model.ExaminationRoomCarType;
    
    CGFloat nameLabelh = [LongHelper textHeight:model.ExaminationRoomName WithUIFont:kPingFangRegular(14) AndWidth:APPwidth-55-CGRectGetMaxX(self.addressTitleLabel.frame)];
    if (nameLabelh < 20) {
        nameLabelh = 20;
    }
    CGFloat addressLabelh = [LongHelper textHeight:model.ExaminationRoomAddress WithUIFont:kPingFangRegular(14) AndWidth:APPwidth-55-CGRectGetMaxX(self.addressTitleLabel.frame)];
    if (addressLabelh < 20) {
        addressLabelh = 20;
    }
    CGFloat cartypeLabelh = [LongHelper textHeight:model.ExaminationRoomCarType WithUIFont:kPingFangRegular(14) AndWidth:APPwidth-55-CGRectGetMaxX(self.addressTitleLabel.frame)];
    if (cartypeLabelh < 20) {
        cartypeLabelh = 20;
    }
    
    self.nameLabel.frame = CGRectMake(CGRectGetMaxX(self.nameTitleLabel.frame)+8, 10, APPwidth-55-CGRectGetMaxX(self.nameTitleLabel.frame), nameLabelh);
    self.addressTitleLabel.frame = CGRectMake(15, CGRectGetMaxY(self.nameLabel.frame)+10, 70, 20);
    self.addressLabel.frame = CGRectMake(CGRectGetMaxX(self.addressTitleLabel.frame)+8, CGRectGetMaxY(self.nameLabel.frame)+10, APPwidth-55-CGRectGetMaxX(self.addressTitleLabel.frame), addressLabelh);
    self.carTypeTitleLabel.frame = CGRectMake(15, CGRectGetMaxY(self.addressLabel.frame)+10, 70, 20);
    self.carTypeLabel.frame = CGRectMake(CGRectGetMaxX(self.carTypeTitleLabel.frame)+8, CGRectGetMaxY(self.addressLabel.frame)+10, APPwidth-55-CGRectGetMaxX(self.carTypeTitleLabel.frame), cartypeLabelh);
    
    self.bjview.frame = CGRectMake(16, 0, APPwidth-32, CGRectGetMaxY(self.carTypeLabel.frame)+10);
    
}






- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
